# -*- coding: utf-8 -*-
#
# Author: QianfuFinance
#
'''
    ``caduceus`` 的持久化对象
'''
from baidustock.database import Base, DBBase, DBSession
from sqlalchemy import Column, String, Integer, Text
import logging


logger = logging.getLogger(__name__)


class Caduceus(Base, DBBase):
    '''
        表 ``caduceus`` 的持久化对象
    '''
    __tablename__ = 'caduceus'

    mail_id = Column('mail_id', Integer, primary_key=True)
    title = Column('title', String(255))
    body = Column('body', Text)
    status = Column('status', String(255))
    body_type = Column('body_type', String(255))
    attachments = Column('attachments', String(255))
    rule_name = Column('rule_name', String(255))

    @classmethod
    def insert(cls, obj):
        '''
            插入对象
        '''
        with DBSession() as session:
            session.add(obj)
            session.flush()
